﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:DeltaEngine.Editor"
	xmlns:helpers="clr-namespace:DeltaEngine.Editor.Helpers"
	xmlns:l="http://wpflocalizeextension.codeplex.com"
	xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Xceed.Wpf.AvalonDock"
	xmlns:avalonDock="http://schemas.xceed.com/wpf/xaml/avalondock"
	l:ResxLocalizationProvider.DefaultAssembly="DeltaEngine.Editor.Core"
	l:ResxLocalizationProvider.DefaultDictionary="Resources"
	x:Class="DeltaEngine.Editor.EditorView"
	mc:Ignorable="d"
	d:DataContext="{d:DesignInstance Type=helpers:DesignEditorViewModel, IsDesignTimeCreatable=True}"
	Title="Delta Engine Editor" Width="1366" Height="750" MinWidth="1024" MinHeight="600"
	WindowStyle="None" ResizeMode="CanResize" BorderThickness="0" Icon="DeltaEngine.Editor.ico"
	MouseDown="OnMouseDown">
	<shell:WindowChrome.WindowChrome>
		<shell:WindowChrome CaptionHeight="0" ResizeBorderThickness="{Binding ResizeBorderThickness}" />
	</shell:WindowChrome.WindowChrome>
	<Window.Resources>
		<Style TargetType="Button" x:Key="DeltaButton">
			<Setter Property="FontSize" Value="14" />
			<Setter Property="FontFamily" Value="Arial" />
			<Setter Property="FontStyle" Value="Normal" />
			<Setter Property="Background">
				<Setter.Value>
					<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
						<GradientStop Color="#FFBBBBBB" Offset="0" />
						<GradientStop Color="#FF9E9E9E" Offset="1" />
					</LinearGradientBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="BorderBrush" Value="Black" />
			<Setter Property="Foreground" Value="#FFFFFFFF" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Border Background="{TemplateBinding Background}">
							<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="IsEnabled" Value="False">
					<Setter Property="Background" Value="#FFCFCFCF" />
				</Trigger>
				<MultiDataTrigger>
					<MultiDataTrigger.Conditions>
						<Condition
							Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
						<Condition
							Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}" Value="True" />
					</MultiDataTrigger.Conditions>
					<Setter Property="Background" Value="#7894d3" />
				</MultiDataTrigger>
			</Style.Triggers>
		</Style>

		<Style x:Key="ActionLabelStyle" TargetType="{x:Type Label}">
			<Setter Property="Margin" Value="10,3" />
			<Setter Property="Padding" Value="0" />
			<Setter Property="TextBlock.TextWrapping" Value="Wrap" />
			<Setter Property="FontFamily" Value="Calibri" />
			<Style.Triggers>
				<MultiTrigger>
					<MultiTrigger.Conditions>
						<Condition Property="IsMouseOver" Value="True" />
						<Condition Property="IsEnabled" Value="True" />
					</MultiTrigger.Conditions>
					<Setter Property="Background" Value="Red" />
				</MultiTrigger>
			</Style.Triggers>
			<Style.Resources>
				<Style TargetType="TextBlock">
					<Style.Triggers>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition
									Binding="{Binding RelativeSource={RelativeSource FindAncestor,
									AncestorType=Label}, Path=IsMouseOver}"
									Value="True" />
								<Condition
									Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}"
									Value="True" />
							</MultiDataTrigger.Conditions>
							<Setter Property="TextDecorations" Value="Underline" />
						</MultiDataTrigger>
					</Style.Triggers>
				</Style>
			</Style.Resources>
		</Style>

		<Style x:Key="TileButton" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Border Background="{TemplateBinding Background}"
						        BorderBrush="{TemplateBinding BorderBrush}"
						        BorderThickness="{TemplateBinding BorderThickness}">
							<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="BorderThickness" Value="0" />
			<Setter Property="Background" Value="#FF7894D3" />
			<Style.Triggers>
				<Trigger Property="IsMouseOver" Value="True">
					<Setter Property="Background" Value="#4e5fb3" />
				</Trigger>
				<Trigger Property="IsPressed" Value="True">
					<Setter Property="Background" Value="#4e5fb3" />
				</Trigger>
			</Style.Triggers>
		</Style>

	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" MinHeight="268" />
			<RowDefinition Height="3" />
			<RowDefinition Height="64" MinHeight="32" />
		</Grid.RowDefinitions>
		<Grid Background="#FFF3F3F3" Grid.Row="0" Grid.RowSpan="2">
			<Image
				Source="Images\WelcomeDeltaLogo.png" Width="184" Height="58"
				HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,7,0,0" />
			<Grid HorizontalAlignment="Left" Background="White" Width="200" Margin="0,74,0,0">
				<ListBox
					Name="EditorPluginSelection"
					ScrollViewer.HorizontalScrollBarVisibility="Disabled"
					IsEnabled="{Binding Path=IsLoggedIn}"
					SelectionChanged="OnEditorPluginSelectionChanged"
					ItemsSource="{Binding Path=EditorPlugins}" BorderBrush="{x:Null}">
					<ListBox.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFFBFBFB" Offset="0" />
							<GradientStop Color="#FFEEEEEE" Offset="1" />
						</LinearGradientBrush>
					</ListBox.Background>
					<ListBox.ItemTemplate>
						<DataTemplate>
							<local:EditorPluginEntryView Width="auto" DataContext="{Binding}" />
						</DataTemplate>
					</ListBox.ItemTemplate>
				</ListBox>
			</Grid>
			<Grid Margin="200,0,0,0" Background="#FFE4E4E4">
				<Grid Visibility="{Binding Path=LoginPanelVisibility}">
					<Grid HorizontalAlignment="Left" Width="1022" Height="718" VerticalAlignment="Top">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="12" />
							<ColumnDefinition Width="30" />
							<ColumnDefinition Width="325" />
							<ColumnDefinition Width="20" />
							<ColumnDefinition Width="15" />
							<ColumnDefinition Width="20" />
							<ColumnDefinition Width="100" />
							<ColumnDefinition Width="130" />
							<ColumnDefinition Width="10" />
							<ColumnDefinition Width="120" />
							<ColumnDefinition Width="10" />
							<ColumnDefinition Width="100" />
							<ColumnDefinition Width="20" />
							<ColumnDefinition />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="12" />
							<RowDefinition Height="40" />
							<RowDefinition Height="12" />
							<RowDefinition Height="30" />
							<RowDefinition Height="12" />
							<RowDefinition Height="40" />
							<RowDefinition Height="12" />
							<RowDefinition Height="9" />
							<RowDefinition Height="21" />
							<RowDefinition Height="20" />
							<RowDefinition Height="13*" />
							<RowDefinition Height="23*" />
							<RowDefinition Height="39*" />
							<RowDefinition Height="120" />
							<RowDefinition Height="10" />
							<RowDefinition Height="120" />
							<RowDefinition Height="10" />
							<RowDefinition Height="120" />
							<RowDefinition Height="55" />
						</Grid.RowDefinitions>
						<Canvas VerticalAlignment="Stretch" Grid.RowSpan="11" Grid.ColumnSpan="8" Grid.Column="5" Grid.Row="1"
						        Margin="0,1,0,22">
							<Canvas.Background>
								<RadialGradientBrush>
									<GradientStop Color="#FFEEEEEE" Offset="0" />
									<GradientStop Color="#FFF9F9F9" Offset="1" />
								</RadialGradientBrush>
							</Canvas.Background>
							<Image Height="41" Canvas.Left="22" Canvas.Top="13" Width="41" Source="Images/LoginKey.png" />
						</Canvas>
						<Label Content="{l:Loc Key=Welcome}" Grid.Column="6" FontSize="22" Foreground="#FF7A7A7A"
						       Margin="50,12,19,23" FontWeight="Bold" Grid.ColumnSpan="7" Grid.Row="1" Grid.RowSpan="3" />
						<Label Content="API Key" VerticalAlignment="Top"
						       Height="27" Background="{x:Null}" Foreground="#FF5D5D5D" FontFamily="Arial" FontSize="14" Grid.Row="3"
						       Grid.Column="6" Margin="0,13,35,0" Grid.RowSpan="2" />
						<TextBox VerticalAlignment="Top" Height="30" FontSize="16" Padding="2,5,0,0"
						         Text="{Binding Path=ApiKey, UpdateSourceTrigger=PropertyChanged}" Foreground="#FF5D5D5D"
						         FontFamily="Arial" Grid.Row="3" Grid.Column="6" Grid.ColumnSpan="6" Margin="69,11,0,0" Grid.RowSpan="2" />
						<Label
							Style="{StaticResource ActionLabelStyle}"
							Foreground="{Binding Path=ErrorForegroundColor}"
							Background="{Binding Path=ErrorBackgroundColor}"
							Margin="0,16,0,0" FontSize="14" Padding="7"
							Visibility="{Binding Path=ErrorVisibility}"
							MouseLeftButtonDown="ErrorClick" Grid.Row="5" Grid.Column="6" Grid.RowSpan="2"
							Height="30" VerticalAlignment="Top" Grid.ColumnSpan="6">
							<TextBlock Text="{Binding Path=Error}" />
						</Label>
						<Button
							Content="{l:Loc Key=Login}" Foreground="White" Style="{StaticResource ResourceKey=TileButton}"
							BorderBrush="{x:Null}" FontSize="22"
							Command="{Binding Path=OnLoginButtonClicked}" FontWeight="Bold" Grid.Row="8" Grid.Column="6" Grid.ColumnSpan="6"
							Grid.RowSpan="2" />
						<Button Grid.ColumnSpan="3" Margin="1,0,0,0" Grid.Column="5" Grid.Row="17"
						        Style="{StaticResource ResourceKey=TileButton}" BorderBrush="{x:Null}"
						        Click="DocumentationClick">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="230" Height="94">
								<TextBlock Text="Documentation" Height="22" Margin="0,1,80,71" Foreground="White" FontSize="16" />
								<Image Source="Images/Documentation.png" Height="81" HorizontalAlignment="Left" Width="56" Margin="5,23,0,-10" />
							</Grid>
						</Button>
						<Button Grid.ColumnSpan="3" Margin="1,0,0,0" Grid.Column="5" Grid.Row="15"
						        Style="{StaticResource ResourceKey=TileButton}" BorderBrush="{x:Null}"
						        Click="TroubleshootingClick">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="230" Height="100">
								<TextBlock Text="Troubleshooting Checklist/ FAQ" Height="22" Foreground="White" FontSize="16" Margin="0,1,0,77" />
								<Image Source="Images/TroubleshootingChecklist.png" Height="64" HorizontalAlignment="Left" Width="55"
								       Margin="0,26,0,4" />
							</Grid>
						</Button>
						<Button Grid.Column="9" Grid.Row="15" Style="{StaticResource ResourceKey=TileButton}" BorderBrush="{x:Null}"
						        Click="StartingWithCsharpClick" Grid.ColumnSpan="4">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="100" Width="230">
								<Image Source="Images/CSharp.png" HorizontalAlignment="Left" Width="72" Margin="3,34,0,0" />
								<TextBlock Text="Starting with C#" Height="24" Foreground="White" FontSize="16" Margin="-50,0,69,76"
								           HorizontalAlignment="Center" />
							</Grid>
						</Button>
						<Button Grid.ColumnSpan="3" Margin="1,0,0,0" Grid.Column="5" Grid.Row="13" BorderBrush="{x:Null}"
						        Click="FirstStepsClick" Style="{StaticResource ResourceKey=TileButton}">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="230" Height="100">
								<TextBlock Text="First Steps" Height="22" Margin="0,-2,80,74" Foreground="White" FontSize="16" />
								<Image Source="Images/FirstSteps.png" Height="87" HorizontalAlignment="Left" Width="60" Margin="0,21,0,-14" />
							</Grid>
						</Button>
						<Button Grid.ColumnSpan="4" Grid.Column="9" Grid.Row="13" Style="{StaticResource ResourceKey=TileButton}"
						        BorderBrush="{x:Null}"
						        Click="TutorialsClick">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="230" Height="94">
								<TextBlock Text="Tutorials" Height="22" Margin="0,-1,80,73" Foreground="White" FontSize="16" />
								<Image Source="Images/Tutorials.png" Height="83" HorizontalAlignment="Left" Width="75" Margin="0,26,0,-15" />
							</Grid>
						</Button>
						<Image Grid.Column="1" HorizontalAlignment="Left" Height="651" Grid.Row="1" Grid.RowSpan="17"
						       VerticalAlignment="Top" Width="386" Source="Images/LoginImage.jpg" Grid.ColumnSpan="4" />
						<Label Content="Getting Started" Grid.Column="4" FontSize="22" Foreground="#FF7A7A7A" Margin="11,14,78,6"
						       FontWeight="Bold" Grid.ColumnSpan="8" Grid.Row="11" Grid.RowSpan="2" />
						<Label
							Content="The Delta Engine allows to write games or &#xA;apps in C#. It is free to use on the  PC. &#xD;&#xA;Convert your apps to other platforms &#xA;(Html5, Android, etc) via our cloud services."
							Grid.Column="2" FontSize="16" Foreground="White" Margin="0,14,0,39" Grid.Row="11" Grid.RowSpan="3" />
						<Button Grid.Column="9" Grid.Row="17" Style="{StaticResource ResourceKey=TileButton}" BorderBrush="{x:Null}"
						        Click="AboutTheEditorClick">
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="100" Width="100">
								<Image Source="Images/Editor.png" HorizontalAlignment="Left" Width="54" Margin="22,9,0,30" />
								<TextBlock Text="Editor" Height="24" Foreground="White" FontSize="16" HorizontalAlignment="Center"
								           VerticalAlignment="Center" Width="54" Margin="28,77,18,-1" />
							</Grid>
						</Button>
						<Button Grid.Column="11" Grid.Row="17" Style="{StaticResource ResourceKey=TileButton}" BorderBrush="{x:Null}"
						        Click="AppBuilderClick" Grid.ColumnSpan="2">
							<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Height="104" Width="112">
								<Image Source="Images/AppBuilder.png" Height="79" HorizontalAlignment="Left" Width="49" Margin="29,0,0,0" />
								<TextBlock Text="App Builder" Height="20" Foreground="White" FontSize="14" Margin="20,0"
								           HorizontalAlignment="Center" />
							</StackPanel>
						</Button>
					</Grid>
				</Grid>
				<Grid Visibility="{Binding Path=EditorPanelVisibility}" Background="#FFE4E4E4">
					<StackPanel
						Margin="0,5,0,0" Orientation="Horizontal"
						VerticalAlignment="Top" HorizontalAlignment="Right">
						<TextBlock
							Margin="0,7,0,0" Foreground="#FF636363" FontSize="14" FontFamily="Arial"
							Text="{Binding Path=PopupText}" Visibility="{Binding Path=PopupVisibility}" />
						<TextBlock
							Margin="10,7,0,0" Foreground="#FF636363" FontSize="14" FontFamily="Arial"
							Text="{Binding Path=VersionNumber}" />
						<Label
							Margin="10,2,0,0" Foreground="#FFA6A6A6" FontSize="14" FontFamily="Arial"
							Content="❘" FontWeight="Bold" />
						<Label
							Margin="5,2,0,0" FontSize="14" FontFamily="Arial"
							Content="Content Project:" Foreground="#FF636363" />
						<ComboBox
							Margin="0,0,0,0" FontSize="14" FontFamily="Arial" MaxDropDownHeight="500"
							Width="200" Padding="5" BorderBrush="{x:Null}" Foreground="#FF636363"
							ItemsSource="{Binding Path=AvailableProjects}"
							SelectedValue="{Binding Path=SelectedProject, Mode=TwoWay}"
							SelectedValuePath="Name"
							IsEnabled="{Binding Path=IsContentReady}"
							DropDownOpened="OnContentProjectDropDownOpened"
							DropDownClosed="OnContentProjectDropDownClosed">
							<ComboBox.Background>
								<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
									<GradientStop Color="#FFB0B0B0" Offset="0" />
									<GradientStop Color="#FFE8E8E8" Offset="1" />
								</LinearGradientBrush>
							</ComboBox.Background>
							<ComboBox.ItemTemplate>
								<DataTemplate>
									<DockPanel>
										<TextBlock
											Text="{Binding Path=Name}" FontWeight="{Binding Path=Weight}" Padding="2,2,2,0" />
									</DockPanel>
								</DataTemplate>
							</ComboBox.ItemTemplate>
						</ComboBox>
						<Button
							Margin="5,0,0,0" Style="{StaticResource DeltaButton}" Width="100"
							Content="Delete Project" Visibility="{Binding Path=DeleteProjectVisibility}"
							Click="DeleteButtonClicked" />
						<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">
							<Image
								Margin="5,0,0,0" Width="30" Height="30"
								Source="{Binding Path=AccountImage}" MouseLeftButtonDown="AccountClick" />
							<Label
								Margin="0,2,200,0" FontSize="14" FontFamily="Arial" FontWeight="Bold"
								Content="{Binding Path=Service.UserName}" MouseLeftButtonDown="AccountClick">
								<Label.Style>
									<Style TargetType="Label">
										<Setter Property="Foreground" Value="#7B7B7B" />
										<Style.Triggers>
											<Trigger Property="IsMouseOver" Value="True">
												<Setter Property="Foreground" Value="Black" />
											</Trigger>
										</Style.Triggers>
									</Style>
								</Label.Style>
							</Label>
							<StackPanel.ContextMenu>
								<ContextMenu>
									<MenuItem Header="DeltaEngine Account" Click="AccountClick" FontWeight="Bold" />
									<MenuItem Header="Forum Profile" Click="ProfileClick" />
									<MenuItem Header="Logout" Command="{Binding Path=OnLogoutButtonClicked}" />
								</ContextMenu>
							</StackPanel.ContextMenu>
						</StackPanel>
					</StackPanel>
					<avalonDock:DockingManager Margin="0,36,0,0" GridSplitterWidth="10" Drop="OnContentDrop" AllowDrop="True">
						<avalonDock:DockingManager.Background>
							<RadialGradientBrush>
								<GradientStop Color="#FFE4E4E4" Offset="1" />
								<GradientStop Color="White" />
							</RadialGradientBrush>
						</avalonDock:DockingManager.Background>
						<avalonDock:DockingManager.Theme>
							<avalonDock:MetroTheme />
						</avalonDock:DockingManager.Theme>
						<avalonDock:LayoutRoot>
							<avalonDock:LayoutPanel>
								<avalonDock:LayoutDocumentPaneGroup x:Name="PluginGroup" />
							</avalonDock:LayoutPanel>
						</avalonDock:LayoutRoot>
					</avalonDock:DockingManager>
				</Grid>
			</Grid>
			<Image
				Margin="0,5,96,0" VerticalAlignment="Top" HorizontalAlignment="Right"
				Width="24" Height="24" MouseDown="OnHelp">
				<Image.Style>
					<Style TargetType="{x:Type Image}">
						<Setter Property="Source" Value="Images/HelpButton.png" />
						<Style.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Source" Value="Images/HelpButtonHover.png" />
							</Trigger>
						</Style.Triggers>
					</Style>
				</Image.Style>
			</Image>
			<Image
				Margin="0,5,65,0" VerticalAlignment="Top" HorizontalAlignment="Right"
				Width="24" Height="24" MouseDown="OnMinimize">
				<Image.Style>
					<Style TargetType="{x:Type Image}">
						<Setter Property="Source" Value="Images/MinimizeWindowButton.png" />
						<Style.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Source" Value="Images/MinimizeWindowButtonHover.png" />
							</Trigger>
						</Style.Triggers>
					</Style>
				</Image.Style>
			</Image>
			<Image
				Margin="0,5,35,0" VerticalAlignment="Top" HorizontalAlignment="Right"
				Width="24" Height="24" MouseDown="OnMaximize">
				<Image.Style>
					<Style TargetType="{x:Type Image}">
						<Setter Property="Source" Value="Images/MaximizeWindowButton.png" />
						<Style.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Source" Value="Images/MaximizeWindowButtonHover.png" />
							</Trigger>
						</Style.Triggers>
					</Style>
				</Image.Style>
			</Image>
			<Image
				Margin="0,5,5,0" VerticalAlignment="Top" HorizontalAlignment="Right"
				Width="24" Height="24" MouseDown="OnExit">
				<Image.Style>
					<Style TargetType="{x:Type Image}">
						<Setter Property="Source" Value="Images/ExitButton.png" />
						<Style.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Source" Value="Images/ExitButtonHover.png" />
							</Trigger>
						</Style.Triggers>
					</Style>
				</Image.Style>
			</Image>
			<Canvas
				Width="200" HorizontalAlignment="Left"
				Margin="0,74,0,0" Background="White" Opacity="0.75"
				Visibility="{Binding Path=LoginPanelVisibility}" />
		</Grid>
		<GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" />
		<Grid Grid.Row="2">
			<TextBox
				VerticalScrollBarVisibility="Visible" Text="{Binding Path=TextLogger.Log, Mode=OneWay}"
				IsReadOnly="True" Name="LogOutput" />
		</Grid>
	</Grid>
</Window>